<?php

/**
 * Celebrio Windows Azure Diagnostics
 *
 * @copyright  Copyright (c) 2011 Celebrio Software
 * @package    WindowsAzure
 */
namespace Celebrio\WindowsAzure\Diagnostics;

use Nette\Object;

use \Microsoft_WindowsAzure_Storage_Blob;
use \Microsoft_WindowsAzure_Storage_Table;
use \Microsoft_WindowsAzure_Diagnostics_Manager;

class DiagnosticsManagement extends Object {

	/**
	 * Adds performance counter to the current role configuration
	 * example: '\Processor(*)\% Processor Time'
	 * @param String $counter
	 */
	public static function addPerformanceCounter($counter) {
		$storageClient = new Microsoft_WindowsAzure_Storage_Blob();
		$manager = new Microsoft_WindowsAzure_Diagnostics_Manager($storageClient);

		$configuration = $manager->getConfigurationForCurrentRoleInstance();

		$configuration->DataSources->PerformanceCounters->addSubscription($counter, 30);
		$configuration->DataSources->OverallQuotaInMB = 10;
		$configuration->DataSources->PerformanceCounters->BufferQuotaInMB = 10;
		$configuration->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes = 2;

		$manager->setConfigurationForCurrentRoleInstance($configuration);
	}
}